home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE07 / SERVER / EXAM1A.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-01-06  |  1.6 KB  |  71 lines

  1. unit Exam1a;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, Grids, DBGrids, DB, DBTables, StdCtrls, Mask, DBCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Query1: TQuery;
  12.     DataSource1: TDataSource;
  13.     btnFind: TButton;
  14.     StoredProc1: TStoredProc;
  15.     Label1: TLabel;
  16.     Label3: TLabel;
  17.     Label4: TLabel;
  18.     edtName: TEdit;
  19.     edtDept: TEdit;
  20.     edtExtension: TEdit;
  21.     edtEmpNo: TEdit;
  22.     Label2: TLabel;
  23.     Database1: TDatabase;
  24.     Button1: TButton;
  25.     DBEdit1: TDBEdit;
  26.     procedure Database1Login(Database: TDatabase; LoginParams: TStrings);
  27.     procedure btnFindClick(Sender: TObject);
  28.     procedure Button1Click(Sender: TObject);
  29.   private
  30.     { Private declarations }
  31.   public
  32.     { Public declarations }
  33.   end;
  34.  
  35. var
  36.   Form1: TForm1;
  37.  
  38. implementation
  39.  
  40. {$R *.DFM}
  41.  
  42. procedure TForm1.Database1Login(Database: TDatabase;
  43.   LoginParams: TStrings);
  44. begin
  45.   LoginParams.Values['USER NAME'] := 'SYSDBA';
  46.   LoginParams.Values['PASSWORD'] := 'masterkey';
  47. end;
  48.  
  49. procedure TForm1.btnFindClick(Sender: TObject);
  50. begin
  51.   with StoredProc1 do
  52.   begin
  53.     ParamByName('EmpNo').AsInteger := StrToInt(edtEmpNo.Text);
  54.     ExecProc;
  55.     if ParamByName('First_Name').IsNull then
  56.       raise Exception.Create('Employee not found');
  57.  
  58.     edtName.Text := ParamByName('First_Name').AsString + ' ' +
  59.                     ParamByName('Last_Name').AsString;
  60.     edtDept.Text := ParamByName('Dept_No').AsString;
  61.     edtExtension.Text := ParamByName('Phone_Ext').AsString;
  62.   end;
  63. end;
  64.  
  65. procedure TForm1.Button1Click(Sender: TObject);
  66. begin
  67.   Halt;
  68. end;
  69.  
  70. end.
  71.